home *** CD-ROM | disk | FTP | other *** search
/ MacHome 2001 May / MacHome CD (May 2001).iso / mac / Stuff / Software / Tools / The Fragmalyzer 1.5.1 / Extras / Headers & Libraries / FrazBinaryFormatPlugins.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-08  |  8.9 KB  |  258 lines  |  [TEXT/CWIE]

  1. /*     
  2.     File:      FrazBinaryFormatPlugins.h
  3.     
  4.     Fragmalyzer Binary Format Plug-in (BFX) Interface
  5.     
  6.     Version:    1.5
  7.     Date:    September 2000
  8.     
  9.     Copyright © 2000 Dan Wright, All rights reserved.
  10.     
  11.     Bugs?:     Please include the name of this file, the version, and the date (above). 
  12.             Send bug reports to danwr@kagi.com. 
  13.     
  14.     Updates:     http://www.halcyon.com/danwr/smoothie.html
  15.     
  16.     Binary Format Plug-ins (BFX) provide support for binary formats. A standard BFX included
  17.     with the Framalyzer 1.5 provides support for PEF fragments; other formats include COFF,
  18.     XCOFF (extended COFF), and Mach-O.
  19.     
  20.     In addition, a BFX may provide support for certain run-time architecture features, such as
  21.     searching for libraries.
  22. */
  23.  
  24. #ifndef __FRAZBINFORMAT__
  25. #define __FRAZBINFORMAT__
  26.  
  27.  
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31.  
  32. #include <Navigation.h>
  33.  
  34. #include "FrazBinaries.h"
  35.  
  36. #ifdef __cplusplus
  37. extern "C"    {
  38. #endif
  39.  
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43.  
  44. #if PRAGMA_STRUCT_ALIGN
  45.     #pragma options align=mac68k
  46. #elif PRAGMA_STRUCT_PACKPUSH
  47.     #pragma pack(push, 2)
  48. #elif PRAGMA_STRUCT_PACK
  49.     #pragma pack(2)
  50. #endif
  51.  
  52.  
  53. enum {
  54. #if TARGET_API_MAC_CARBON
  55.     kFrazBFXCurrentVersion        = 2,
  56. #else
  57.     kFrazBFXCurrentVersion         = 1,
  58. #endif
  59.  
  60. #if TARGET_RT_MAC_CFM
  61.     #if TARGET_API_MAC_CARBON
  62.         kFrazBFXCallbackMagic     = FOUR_CHAR_CODE('bfx*')
  63.     #else
  64.         kFrazBFXCallbackMagic    = FOUR_CHAR_CODE('abi*')
  65.     #endif
  66. #else
  67.     kFrazBFXCallbackMagic    = FOUR_CHAR_CODE('bfx!')
  68. #endif
  69.     };
  70.  
  71. typedef struct OpaqueScanContext *    FrazScanContext;
  72.  
  73. typedef struct OpaqueSymbol *        SymbolRef;
  74.  
  75.  
  76. enum {
  77.     // properties that have special types not for AppleScript consumption
  78.     kFrazPropTypePrivate     = FOUR_CHAR_CODE(']]]]'),
  79.     // properties that have special types not for AS and cannot be modified exc. by BFX
  80.     kFrazPropTypePrivateReadOnly = FOUR_CHAR_CODE('[[[['),
  81.     // properties that are completely invisible to anyone but the BFX
  82.     kFrazPropTypePrivateInvisible = 0
  83.     };
  84.  
  85. typedef OSErr (*AddLocatorProcPtr)(FrazScanContext, BrowserRef, BinFormat, const FrazLocator *, ConstStr255Param);
  86. typedef OSErr (*RemoveFragmentProcPtr)(FrazScanContext, FragmentRef);
  87. typedef OSErr (*AddInformationProcPtr)(FragmentRef, OSType, void *, Size);
  88. typedef OSErr (*SetSectionPropertyProcPtr)(FragmentRef, SInt16 section, OSType property, DescType, void *pvalue, Size cbValue);
  89. typedef OSErr (*AddLibraryProcPtr)(FragmentRef, ConstStr255Param stLibrary, LibraryRef *plibrary);
  90. typedef OSErr (*SetLibraryPropertyProcPtr)(LibraryRef, OSType property, DescType, void *pvalue, Size cbValue);
  91. typedef OSErr (*AddSymbolProcPtr)(FragmentRef, LibraryRef, ConstStr255Param stSymbol, SymbolRef *psymbol);
  92. typedef OSErr (*SetSymbolPropertyProcPtr)(SymbolRef, OSType property, DescType, void *pvalue, Size cbValue);
  93. typedef OSErr (*SetFragmentPropertyProcPtr)(FragmentRef, OSType, DescType, void *, Size);
  94.  
  95.  
  96. enum { /* FrazFilterParam.flags, FrazScanParam.flags */
  97.     kFrazSharedLibrariesOnlyMask     = 0x0001,
  98.     kFrazNeverInteractMask        = 0x0002,    /* always set in FrazFilterParam.flags */
  99.     kFrazSearchingMask            = 0x0004,    /* window shopping: we don't need a clerk yet, thank you very much */
  100.     kFrazValidationBasicMask        = 0x0010,    /* verify basic fragment structure (scan only) */
  101.     kFrazValidationWarningsMask    = 0x0020        /* further validation */
  102.     };
  103.     
  104. enum { /* FrazFilterParam.where */
  105.     kFrazFileSpec = 1,
  106.     kFrazNavSpec,
  107.     kFrazProcess,
  108.     kFrazContext
  109.     };
  110.  
  111. typedef struct FrazFilterParam
  112.     {
  113.     UInt16 flags;
  114.     UInt16 where;
  115.     union {
  116.         struct {
  117.             ConstFSSpecPtr    pfile;
  118.             CInfoPBPtr         catInfo;        
  119.             } fileSpec;                        /* 8 */
  120.         struct {
  121.             const AEDesc *        paeDesc;
  122.             const NavFileOrFolderInfo *navInfo;
  123.             } navSpec;                    /* 8 */
  124.         ProcessSerialNumber process;            /* 8 */
  125.         CFragContextID     context;            /* 4 */
  126.         } u;
  127.     } FrazFilterParam;
  128.  
  129. typedef struct FrazScanParam
  130.     {
  131.     UInt16 flags;
  132.     UInt16 where;
  133.     union {
  134.         ConstFSSpecPtr        pfileSpec;
  135.         ProcessSerialNumber    process;
  136.         CFragContextID            context;
  137.         } u;
  138.     } FrazScanParam;
  139.  
  140. typedef struct FrazFindParam
  141.     {
  142.     UInt16        flags;
  143.     UInt16        reserved;
  144.     BinFormat        binFormat;
  145.     FragmentRef    fragment;
  146.     LibraryRef    library;
  147.     } FrazFindParam;
  148.     
  149.  
  150. typedef struct FrazLibSearch
  151.     {
  152.     UInt32    privateData[4];
  153.     } FrazLibSearch;
  154.     
  155. enum {
  156.     kDontCacheThisSearch = 0
  157.     };
  158.     
  159. /*
  160.     prototypes for BFX entrypoints
  161. */
  162.  
  163. /*    BFXFilter - determines which files/processes contain fragments of the supported binary format (required) */
  164. Boolean     BFXFilter(const FrazFilterParam *);
  165.  
  166. /*     BFXScan - identifies all fragments of our binary format in the specified file/process (required)
  167.         If no fragments are found, should return errNoFragmentsFound instead of noErr.     */
  168. OSErr     BFXScan(FrazScanContext, const FrazScanParam *);
  169.  
  170. /*    BFXGetFragmentInfo - identifies libraries, section, and fragment properties of the specified fragment (required) */
  171. OSErr     BFXGetFragmentInfo(FrazScanContext, FragmentRef, ConstFrazLocatorPtr);
  172.  
  173. /*    BFXGetImportedSymbols - builds the list of imported symbols (optional) */
  174. OSErr     BFXGetImportedSymbols(FrazScanContext, FragmentRef, LibraryRef, ConstFrazLocatorPtr);
  175.  
  176. /*    BFXGetExportedSymbols - builds the list of exported symbols (optional) */
  177. OSErr     BFXGetExportedSymbols(FrazScanContext, FragmentRef, ConstFrazLocatorPtr);
  178.  
  179. /*     BFXGetSymbolProperty - obtains one property (in AEDesc form) for the specified symbol (optional) */
  180. OSErr     BFXGetSymbolProperty(FrazScanContext, FragmentRef, LibraryRef, ConstFrazLocatorPtr,
  181.                             UInt32 indexSymbol, ConstStr255Param stMangled, 
  182.                             OSType property, AEDesc *);
  183.  
  184. /*    BFXGetFragmentSizeReal - determines the exact size (in bytes) of the specified fragment (optional) */
  185. OSErr     BFXGetFragmentSizeReal(FrazLocatorRef, UInt32 *pcb);
  186.  
  187.     
  188. /*    BFXFind/BFXFindLibrary - locate the library (optional) */
  189. OSErr     BFXFind(FrazScanContext, const FrazFindParam *);
  190. OSErr     BFXFindLibrary(FrazScanContext, BinFormat, FragmentRef, LibraryRef);
  191.  
  192. /*
  193.     APIs available exclusively to Binary Format Plug-ins
  194. */
  195. pascal OSErr FrazAddLocator(FrazScanContext, BrowserRef, BinFormat, const FrazLocator *, ConstStr255Param);
  196. pascal OSErr FrazRemoveFragment(FrazScanContext, FragmentRef);
  197. pascal OSErr FrazSetFragmentProperty(FrazScanContext, FragmentRef, OSType property, DescType, void *, Size);
  198.  
  199. pascal OSErr FrazAddSymbol(FrazScanContext, FragmentRef, LibraryRef, ConstStr255Param stSymbol, SymbolRef *psymbol);
  200. pascal OSErr FrazAddLibrary(FrazScanContext, FragmentRef, ConstStr255Param stLibrary, LibraryRef *plibrary);
  201. pascal OSErr FrazSetSymbolProperty(FrazScanContext, SymbolRef, OSType property, DescType, void *pvalue, Size cbValue);
  202. pascal OSErr FrazSetLibraryProperty(FrazScanContext, LibraryRef, OSType property, DescType, void *pvalue, Size cbValue);
  203. pascal OSErr FrazSetSectionProperty(FrazScanContext, FragmentRef, SInt16 section, OSType property, DescType type, void *pvalue, Size cbValue);
  204. pascal OSErr FrazSetLibraryIntegerProperty(FrazScanContext, LibraryRef, OSType property, long value);
  205. pascal OSErr FrazSetSectionIntegerProperty(FrazScanContext, FragmentRef, SInt16 section, OSType property, long value);
  206. pascal OSErr FrazSetFragmentIntegerProperty(FrazScanContext, FragmentRef, OSType property, long value);
  207. pascal OSErr FrazSetLibraryBooleanProperty(FrazScanContext, LibraryRef, OSType property, Boolean value);
  208. pascal OSErr FrazSetFragmentBooleanProperty(FrazScanContext, FragmentRef, OSType property, Boolean value);
  209. pascal OSErr FrazSetSymbolBooleanProperty(FrazScanContext, SymbolRef, OSType property, Boolean value);
  210. pascal OSErr FrazSetSymbolIntegerProperty(FrazScanContext, SymbolRef, OSType property, long value);
  211.  
  212. /* Segment property support is not yet implemented: */
  213. pascal OSErr FrazSetSegmentProperty(FrazScanContext, FragmentRef, SInt16 segment, OSType property, DescType, void*, Size);
  214. pascal OSErr FrazSetSegmentIntegerProperty(FrazScanContext, FragmentRef, SInt16 segment, OSType property, long value);
  215. pascal OSErr FrazSetSegmentBooleanProperty(FrazScanContext, FragmentRef, SInt16 segment, OSType property, Boolean value);
  216.  
  217. /*    FrazScanContextIsValid - determines whether the context is (still) valid. It may become invalid, for example,
  218.     if the browser window has been closed. */
  219. pascal Boolean FrazScanContextIsValid(FrazScanContext);
  220.  
  221. /*    FrazBrowserFromScanContext - determines the browser used for the context. Note: in some cases, there may
  222.     be no browser associated with the context. */
  223. pascal BrowserRef FrazBrowserFromScanContext(FrazScanContext);
  224.  
  225. /*
  226.     library searches
  227. */
  228. pascal OSErr FrazBeginLibrarySearch(BinFormat, short vRefNum, long pluginSearchRefCon, FrazLibSearch *);
  229. pascal OSErr FrazAddFileToSearch(FrazLibSearch *, ConstFSSpecPtr);
  230. pascal OSErr FrazAddDirectoryToSearch(FrazLibSearch *, long dirID, short nSearchDepth, OSType ftyp);
  231. pascal OSErr FrazGetNextLibrary(FrazLibSearch *, ConstStr255Param stLibrary, FrazLocator *plocator);
  232. pascal OSErr FrazEndLibrarySearch(FrazLibSearch *);
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240. #if PRAGMA_STRUCT_ALIGN
  241.     #pragma options align=reset
  242. #elif PRAGMA_STRUCT_PACKPUSH
  243.     #pragma pack(pop)
  244. #elif PRAGMA_STRUCT_PACK
  245.     #pragma pack()
  246. #endif
  247.  
  248. #ifdef PRAGMA_IMPORT_OFF
  249. #pragma import off
  250. #elif PRAGMA_IMPORT
  251. #pragma import reset
  252. #endif
  253.  
  254. #ifdef __cplusplus
  255.         }
  256. #endif
  257.  
  258. #endif /* __FRAZBINFORMAT__ */